package com.work.vo.main;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.work.constant.DictBizConstant;
import com.work.constant.TallyType;
import com.work.utils.BigDecimalSerializer;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springblade.core.tool.utils.Func;
import org.springblade.system.cache.DictBizCache;

import java.math.BigDecimal;
import java.time.LocalDate;

/**
 * 散货外捣解锁详情
 *
 * @author ：dujianyu
 * @since ：Created in 2024/6/18 15:22
 */
@Data
public class BulkTallyUnlockDetailVO {

    @JsonSerialize(using = ToStringSerializer.class)
    @ApiModelProperty(value = "id")
    private Long id;

    @JsonSerialize(using = ToStringSerializer.class)
    @ApiModelProperty(value = "transportShipId")
    private Long transportShipId;

    @ApiModelProperty(value = "船名")
    private String shipNameZh;

    @ApiModelProperty(value = "进口航次")
    private String impVoyage;

    @ApiModelProperty(value = "出口航次")
    private String expVoyage;

    @ApiModelProperty(value = "理货日期")
    private LocalDate tallyDate;

    @ApiModelProperty(value = "时间段")
    private String timeSpace;

    public String getTimeSpaceName() {
        if (Func.isNull(timeSpace)) {
            return "";
        }
        return DictBizCache.getValue(DictBizConstant.TIME_SPACE, timeSpace);
    }

    @ApiModelProperty(value = "货名")
    private String cargoType;

    @ApiModelProperty(value = "货名")
    private String cargoTypeName;

    @JsonSerialize(using = ToStringSerializer.class)
    @ApiModelProperty(value = "作业过程")
    private Long operationType;

    @ApiModelProperty(value = "作业过程")
    private String operationTypeName;

    @ApiModelProperty(value = "作业活动")
    private String workActivityName;

    @ApiModelProperty(value = "理货方式")
    private String tallyType;

    @ApiModelProperty(value = "理货方式")
    private String tallyTypeName;

    public String getTallyTypeName() {
        if (Func.isNull(tallyType)) {
            return "";
        }
        return DictBizCache.getValue(DictBizConstant.TALLY_TYPE, tallyType);
    }

    @ApiModelProperty(value = "作业舱")
    private String hold;

    @ApiModelProperty(value = "作业舱")
    private String holdName;

    @JsonSerialize(using = ToStringSerializer.class)
    @ApiModelProperty(value = "作业前货场ID")
    private Long oriPositionId;

    @ApiModelProperty(value = "作业前货场名称")
    private String oriPositionName;

    @ApiModelProperty(value = "作业前货位")
    private String oriSpot;

    @JsonSerialize(using = BigDecimalSerializer.class)
    @ApiModelProperty(value = "作业前吨数")
    private BigDecimal oriTon;

    @JsonSerialize(using = ToStringSerializer.class)
    @ApiModelProperty(value = "作业后货场ID")
    private Long toPositionId;

    @ApiModelProperty(value = "作业后货场名称")
    private String toPositionName;

    @ApiModelProperty(value = "作业后货位")
    private String toSpot;

    @JsonSerialize(using = BigDecimalSerializer.class)
    @ApiModelProperty(value = "作业后吨数")
    private BigDecimal toTon;

    @ApiModelProperty(value = "机械")
    private String machineInfo;

    @ApiModelProperty(value = "工人")
    private String workerInfo;

    @ApiModelProperty(value = "安全生产")
    private String isSafeProduction;

    public String getIsSafeProductionName() {
        if (Func.isNull(isSafeProduction)) {
            return "";
        }
        return "Y".equals(isSafeProduction) ? "是" : "否";
    }

    @JsonSerialize(using = ToStringSerializer.class)
    @ApiModelProperty(value = "保管员")
    private Long keeper;

    @ApiModelProperty(value = "保管员")
    private String keeperName;

    @ApiModelProperty(value = "备注")
    private String remark;

    @ApiModelProperty(value = "货场信息")
    private String positionInfo;

    public String getPositionInfo() {
        if (Func.isNull(oriPositionId)) {
            return "";
        }

        if (TallyType.VARIOUS.equals(tallyType)) {
            return oriPositionName + "->" + toPositionName;
        }

        return oriPositionName;
    }

    @ApiModelProperty(value = "货位信息")
    private String spotInfo;

    public String getSpotInfo() {
        if (Func.isNull(oriSpot)) {
            return "";
        }

        if (TallyType.VARIOUS.equals(tallyType)) {
            return oriSpot + "->" + toSpot;
        }

        return oriSpot;
    }

    @ApiModelProperty(value = "吨信息")
    private String tonInfo;

    public String getTonInfo() {
        if (Func.isNull(oriTon)) {
            return "";
        }

        if (TallyType.VARIOUS.equals(tallyType)) {
            return oriTon.stripTrailingZeros().toPlainString() + "->" + toTon.stripTrailingZeros().toPlainString();
        }

        return oriTon.stripTrailingZeros().toPlainString();
    }
}
